﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading.Tasks;

namespace networkTestUtilities
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            protoTest.host = "localhost";
            protoTest.port = 7777;

            Console.WriteLine("Beginning test...");

            List<protoTest> lpT = new List<protoTest>();
            for(int i = 0; i <100; i++)
            {
                lpT.Add(new protoTest());
            }

           // protoTest pT = new protoTest();

            lpT[0].runTest();

            Parallel.ForEach(lpT, (item) => item.runTest());


            //for(int i = 0; i < 10; i++)
            //pT.runTest();
            Console.WriteLine("... test complete.");
            //System.Net.Sockets.TcpClient tc1 = new System.Net.Sockets.TcpClient();
            //tc1.Connect("localhost", 7777);

            //System.Net.Sockets.NetworkStream n = tc1.GetStream();

            //n.Write(new byte[] { 0x00, 0x05, 0x01, 0x02, 0x03, 0x04, 0x05, 0x02, 0x03, 0x11, 0x12, 0x012 }, 0, 12);

            //System.     .Thread.Sleep(10);

            //byte[] response = new byte[14];
            //for (int i = 0; i < 14; i++)
            //{
            //    int byteValue = n.ReadByte();
            //    if (byteValue == -1)
            //    {
            //        Console.WriteLine("Byte stream terminated prematurely");
            //    }
            //    else
            //    {
            //        response[i] = (byte) byteValue;
            //    }
            //}

            Console.WriteLine("Response Received.");

            //tc1.Close();

        }
    }
}
